package com.dream.keigezhushou.Activity.kege.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;

import com.dream.keigezhushou.R;

/**
 * Created by Administrator on 2017/3/16.
 */
public class ChoralListAdapter extends BaseAdapter {

    private Context mContext;
    int c = 12;
    public ItemOnClickListening itemOnClickLinister=null;
    int postion;


    public void  setItemOnClickListening(ItemOnClickListening listening){
        this.itemOnClickLinister=listening;
    }
    public ChoralListAdapter(Context context) {
        this.mContext=context;
    }

    @Override
    public int getCount() {
        return c;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        postion=i;
        ProHolder mHolder = null;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.item_choral_list,null);
            mHolder = new ProHolder();

            mHolder.itemLinear=(LinearLayout) view.findViewById(R.id.item_chorus_linear);



            view.setTag(mHolder);
        }else {
            mHolder = (ProHolder)view.getTag();
        }


        mHolder.itemLinear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemOnClickLinister!=null){

                    itemOnClickLinister.itemClick(postion);
                }
            }
        });


        return view;
    }


    class ProHolder{

        LinearLayout itemLinear;

    }



    public interface ItemOnClickListening{
        public void itemClick(int postion);
    }


}